# Contributor: Orhun Parmaksız <orhunparmaksiz@gmail.com>
# Maintainer: Orhun Parmaksız <orhunparmaksiz@gmail.com>
pkgname=repgrep
_pkgname=rgr
pkgver=0.14.3
pkgrel=0
pkgdesc="Interactive command line replacer for ripgrep"
url="https://github.com/acheronfail/repgrep"
arch="all"
license="MIT OR Apache-2.0 OR Unlicense"
depends="ripgrep"
makedepends="
	cargo
	cargo-auditable
	asciidoctor
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/acheronfail/repgrep/archive/$pkgver.tar.gz"
options="net"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -Dm 755 "target/release/$_pkgname" -t "$pkgdir/usr/bin"
	install -Dm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname"
	install -Dm 644 LICENSE-MIT -t "$pkgdir/usr/share/licenses/$pkgname"
	out_dir=$(find target -name repgrep-stamp -print0 | xargs -0 ls -t | head -n1 | xargs dirname)
	install -Dm 644 "$out_dir/$_pkgname.bash" "$pkgdir/usr/share/bash-completion/completions/$_pkgname"
	install -Dm 644 "$out_dir/$_pkgname.fish" "$pkgdir/usr/share/fish/vendor_completions.d/$_pkgname.fish"
	install -Dm 644 "$out_dir/_$_pkgname" "$pkgdir/usr/share/zsh/site-functions/_$_pkgname"
	install -Dm 644 "$out_dir/$_pkgname.1" -t "$pkgdir/usr/share/man/man1"
}

sha512sums="
15848e1db1ef4dbd46c1ae1ff1ce29b8bf13adffdd81e0b6648fe200dd6b22fe9e8fb9706770cae4639d2df76d8b0143c1ce79fd9e5565b9983b1b1371c234b9  repgrep-0.14.3.tar.gz
"
